package com.tarena.lbs.business.dao.mapper;

import com.tarena.lbs.business.pojo.po.StorePO;
import com.tarena.lbs.business.pojo.query.StoreQuery;
import com.tarena.lbs.business.pojo.vo.StoreVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StoreMapper {
    //查询当前页数据
    List<StoreVO> pageList(StoreQuery query);
    //查询总记录数
    int count(StoreQuery query);
//        <insert id="insert" parameterType="com.tarena.lbs.business.pojo.po.StorePO" useGeneratedKeys="true" keyProperty="id">
//            INSERT INTO lbs_store (
//                business_id, store_name, store_phone, store_head_name, store_head_phone,
//                province_id, city_id, area_id, store_location, store_longitude, store_latitude,
//                store_images_id, store_logo, store_introduction, sort, trade_time, store_status,
//                create_time, update_time
//            ) VALUES (
//                         #{businessId}, #{storeName}, #{storePhone}, #{storeHeadName}, #{storeHeadPhone},
//                         #{provinceId}, #{cityId}, #{areaId}, #{storeLocation}, #{storeLongitude}, #{storeLatitude},
//                         #{storeImagesId}, #{storeLogo}, #{storeIntroduction}, #{sort}, #{tradeTime}, #{storeStatus},
//                         #{createTime}, #{updateTime}
//                     )
//        </insert>
    @Insert( "<script> INSERT INTO lbs_store (\n" +
            "                business_id, store_name, store_phone, store_head_name, store_head_phone,\n" +
            "                province_id, city_id, area_id, store_location, store_longitude, store_latitude,\n" +
            "                store_images_id, store_logo, store_introduction, sort, trade_time, store_status,\n" +
            "                create_time, update_time\n" +
            "            ) VALUES (\n" +
            "                         #{businessId}, #{storeName}, #{storePhone}, #{storeHeadName}, #{storeHeadPhone},\n" +
            "                         #{provinceId}, #{cityId}, #{areaId}, #{storeLocation}, #{storeLongitude}, #{storeLatitude},\n" +
            "                         #{storeImagesId}, #{storeLogo}, #{storeIntroduction}, #{sort}, #{tradeTime}, #{storeStatus},\n" +
            "                         #{createTime}, #{updateTime})</script>")
    @Options( useGeneratedKeys = true, keyProperty = "id")
    int insert(StorePO po);


    int deleteById(@Param("id") Integer id);
    int updateStatus(@Param("id") Integer id, @Param("status") Integer status);
    // 新增：按多城市ID查询店铺
//    List<StoreVO> getStoreByCityIds(AreaStoreQuery query);
//    int countByCityIds(AreaStoreQuery query);
}